fs: fix writeFile[Sync] for non-seekable files#32006
fs: fix writeFile[Sync] for non-seekable files#32006mildsunrise wants to merge 1 commit intonodejs:masterfrom
Conversation
Completely disables the use of positioned writes at writeFile and writeFileSync, which allows it to work with non-seekable files. Fixes: nodejs#31926
|
This variant is the one that does change behaviour in the custom-FD use case, right? I feel like 99.9 % of people wouldn’t be affected, but maybe we could still keep that for a separate PR? |
addaleax
left a comment
There was a problem hiding this comment.
Right, thanks for reminding me :)
|
No prob! It was more than a year ago, I'd have forgotten too 😹 |
|
CI: https://ci.nodejs.org/job/node-test-pull-request/29452/ (:white_check_mark:) |
Codecov Report
@@ Coverage Diff @@
## master #32006 +/- ##
=======================================
Coverage 96.16% 96.16%
=======================================
Files 196 196
Lines 64918 64918
=======================================
Hits 62429 62429
Misses 2489 2489Continue to review full report at Codecov.
|
|
Landed in f69de13 🎉 |
|
This does not land cleanly on v13.x. Should it be backported? |
|
@MylesBorins Wrong label? And, yes, it should be backported. 👍 |
Completely disables the use of positioned writes at writeFile and writeFileSync, which allows it to work with non-seekable files. Fixes: nodejs#31926 PR-URL: nodejs#32006 Reviewed-By: Anna Henningsen <anna@addaleax.net>
Currently
writeFileandwriteFileSyncperform a positioned write at the beginning of the file, which prevents them from working with non-seekable files (#31926).Positioned writes were first removed for
createWriteStream(#19329) and for custom FDs (#23433, #23709) as well as for files opened in append mode... but they're still used for filenames in normal mode. This PR removes positioned writes completely, as they're not needed for this case either.This also makes it consistent with
readFile(which does work with non-seekable files).Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes